package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.product.service.FileService;
import io.minio.errors.InvalidEndpointException;
import io.minio.errors.InvalidPortException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @author lhh
 * @ClassName FileController
 * @date 2022 2022/12/1
 */
@Api(tags = "文件管理")
@RestController
@RequestMapping("/admin/product")
public class FileController {

    @Resource
    FileService fileService;

    @ApiOperation(value = "图片上传")
    @PostMapping("fileUpload")
    public Result fileUpload(@RequestPart MultipartFile file) throws Exception {
        String url=fileService.fileUpload(file);
        return Result.ok(url);
    }
}
